package com.project.controller;


import com.project.entity.po.Employee;
import com.project.result.ResponseResult;
import com.project.service.EmployeeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Resource
    EmployeeService employeeService;

    @GetMapping("/select/all/employee")
    public ResponseResult<List<Employee>> selectAllEmployee(){
        return employeeService.selectAllEmployee();
    }

    @PostMapping("/update/employee/id")
    public ResponseResult<Integer> updateEmployeeById(Long id){
        return employeeService.updateEmployeeById(id);
    }

    @GetMapping("/select/employee/name")
    public ResponseResult<List<Employee>> selectEmployeeByName(String name,Integer status){
        return employeeService.selectEmployeeByName(name,status);
    }

    @GetMapping("/select/employee/id")
    public ResponseResult<Employee> selectEmployeeById(Long id){
        return employeeService.selectEmployeeById(id);
    }


    @PutMapping("/insert/employee")
    public ResponseResult<Integer> insertEmployee(@RequestBody Employee employee){
        return employeeService.insertEmployee(employee);
    }



    @PostMapping("/update/employee")
    public ResponseResult<Integer> updateEmployee(@RequestBody Employee employee){
        return employeeService.updateEmployee(employee);
    }


    @PostMapping("/update/employee/duty/id")
    public ResponseResult<Integer> updateEmployeeByDutyId(Long dutyId, Long id){
        return employeeService.updateEmployeeByDutyId(dutyId,id);
    }
}
